{% extends "base.html" %}
{{form.as_p}}

<script>
function toggleDiv(divId) {
    $("#"+divId).toggle(500);
}
</script>
{% load widget_tweaks %}

{% block content %}
<form method="post">
    {% csrf_token %}

    {% for hidden_field in orders_form.hidden_fields %}
        {{ hidden_field }}
    {% endfor %}

    {% for field in orders_form.visible_fields %}
        <div class="form-group">
          {{ field.label_tag }}
              {% render_field field class="form-control" %}
          {% if field.help_text %}
            <small class="form-text text-muted">{{ field.help_text }}</small>
          {% endif %}
        </div>
    {% endfor %}

    <input type="submit" name="orders" id="orders" value="Подготовить данные">
</form>
<div class="row">
    <div class="col">
        <table class="table">
            <thead>
            <tr>
                <th scope="col">Время загрузки</th>
                <th scope="col">Пользователь</th>
                <th scope="col">Файл</th>
            </tr>
            </thead>
            <tbody>
            {% for order in last_orders %}
                <tr>
                    <td scope="col">{{order.datetime}}</td>
                    <td scope="col">{{order.user}}</td>
                    <td scope="col">{{order.file_field.name}}</td>
                </tr>
            {% endfor %}
        </tbody>
    </table>
    </div>
</div>
{% endblock %}
